package com.camel.chart.utils.entity;

import lombok.Data;

import java.io.Serializable;
import java.util.Objects;

/**
 * 所有网络设备
 */
@Data
public class NetDevice implements Serializable {

    private static final long serialVersionUID = 1L;

    private String name;

    private String remark;

    private String inetAddress;

    public boolean myDevice;

    public boolean online;

    public static String myInetAddress;

    /**
     * 是否是聊天室设备
     */
    private boolean chartClient;

    public NetDevice() {
    }

    public NetDevice(String inetAddress) {
        this.inetAddress = inetAddress;
    }


    public NetDevice(String inetAddress, boolean online) {
        this.inetAddress = inetAddress;
        this.online = online;
    }

    public boolean isMyDevice() {
        return Objects.equals(this.inetAddress, ApplicationConfig.getInstance().getChartNetWorkInterface().getLocalIPStr());
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        NetDevice netDevice = (NetDevice) o;
        return netDevice.getInetAddress().equals(this.inetAddress);
    }

    @Override
    public int hashCode() {
        return Objects.hash(inetAddress);
    }
}
